package ar.com.digitalbricks.view.imprenta.helper.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;

import ar.com.digitalbricks.imprenta.cliente.enums.TipoIva;
import ar.com.digitalbricks.imprenta.cliente.mgr.ClienteMgr;
import ar.com.digitalbricks.imprenta.persona.mgr.ContactoMgr;
import ar.com.digitalbricks.view.imprenta.general.EnumView;
import ar.com.digitalbricks.view.imprenta.helper.ClienteView;
import ar.com.digitalbricks.view.imprenta.helper.TelefonoView;

import com.opensymphony.xwork2.ActionSupport;

public class ViewHelperAction extends ActionSupport {
	private static ClienteMgr clienteMgr;
	private static ContactoMgr contactoMgr;
	private String idContacto;
	
	public List<ClienteView> getClientes(){
		return this.getClienteMgr().getAllClientesActivos();
	}
	
	@SuppressWarnings("unchecked")
	public List<EnumView> getTiposIva(){
		List<EnumView> list = new ArrayList<EnumView>();
		for (Enum unTipoIva : EnumSet.allOf(TipoIva.class)) {
			EnumView enumView = new EnumView(unTipoIva);
			list.add(enumView);
		}
		return list;
	}
	
	public Collection<TelefonoView> getTelefonos(){
		if (this.getIdContacto() != null){
			return this.getContactoMgr().findAllTelefonosByContactoId(this.getIdContacto());
		}
		return null;
	}
	
	public String getIdContacto() {
		return this.idContacto;
	}

	public void setIdContacto(String idContacto) {
		this.idContacto = idContacto;
	}

	public ClienteMgr getClienteMgr() {
		return clienteMgr;
	}
	
	@SuppressWarnings("static-access")
	public void setClienteMgr(ClienteMgr clienteMgr) {
		this.clienteMgr = clienteMgr;
	}
	
	public ContactoMgr getContactoMgr() {
		return contactoMgr;
	}

	@SuppressWarnings("static-access")
	public void setContactoMgr(ContactoMgr contactoMgr) {
		this.contactoMgr = contactoMgr;
	}
}